package com.enjoyor.soa.traffic.rest.tsms.thread;

import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import com.alibaba.fastjson.JSONObject;
import com.enjoyor.soa.traffic.api.serverpush.server.dubbo.DubboServerPushService;
import com.enjoyor.soa.traffic.rest.tsms.TsmsRestApplication;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

/**
 * 消息推送线程
* @ClassName: MessagePushThread 
* @Description: TODO(这里用一句话描述这个类的作用) 
* @author 
* @date 
*
 */
public class MessagePushThread implements Runnable {
	//消息推送线程
	public static BlockingQueue<Map<String, String>> messageQueue = new ArrayBlockingQueue<Map<String, String>>(15);
	private DubboServerPushService pushservice = null;

	@SuppressWarnings("unused")
	@Override
	public void run() {
		pushservice = TsmsRestApplication.context.getBean(DubboServerPushService.class);
		while(true){
			Map<String, String> notifyMap = null;
			try {
				notifyMap = messageQueue.remove();
				//notify = new NotifyInfoDto();
			} catch (Exception e) {
				notifyMap = null;
			}
			if(notifyMap != null) {
				JSONObject sendMsg = JSONObject.parseObject(notifyMap.get("messageDetail"));
				ResultPojo result = pushservice.pushMessage("messageListen",sendMsg);
			}
		}
	}

}
